/*
 * CalendarHandler.java
 *
 * Created on October 31, 2006, 3:23 PM
 *
 */

package com.asaga.tools;
import java.io.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;

import java.sql.*;
import java.util.*;
/**
 *
 * @author mmixon
 */
public class CalendarHandler {
    private Event_DBImpl event;
    private Location_StubImpl location;
    String locationid;
    /**
     * Creates a new instance of CalendarHandler
     */
    public CalendarHandler() {
    }
    public CalendarHandler(HttpServletRequest request){
        event = new Event_DBImpl();
        location = new Location_StubImpl();
        String starthr = request.getParameter("starthr");
        String startmin = request.getParameter("startmin");
        String startmer = request.getParameter("startmer");
        String endhr = request.getParameter("endhr");
        String endmin = request.getParameter("endmin");
        String endmer = request.getParameter("endmer");
        String startTime = starthr + ":" + startmin + ":00" + " " + startmer;
        String endTime = endhr + ":" + endmin + ":00" + " " + endmer;
        locationid = request.getParameter("locationid");
        event.setTitle(request.getParameter("title"));
        event.setStartDate(request.getParameter("startDate"));
        event.setEndDate(request.getParameter("endDate"));
        event.setStartTime(startTime);
        event.setWarningMessage("Is this information correct?");
        event.setEndTime(endTime);
        if((locationid == "") || (locationid == null)){
            event.setWarningMessage("Please Select a Location" +
                    " or insert location information.");
        }
        else if((locationid.equals("notlisted"))){
            location.setTitle(request.getParameter("locationTitle"));
            location.setAddr1(request.getParameter("addr1"));
            location.setAddr2(request.getParameter("addr2"));
            location.setCity(request.getParameter("city"));
            location.setState(request.getParameter("state"));
            location.setZip(Integer.parseInt(request.getParameter("zip")));
            location.setWebsite(request.getParameter("website"));
            location.setContactName(request.getParameter("contactName"));
            location.setContactEmail(request.getParameter("contactEmail"));
        }
        else{
            location.setId(Integer.parseInt(locationid));
            location.setVenueById(Integer.parseInt(locationid));
        }
    }
    public Event_DBImpl getEvent(){
        return event;
    }
    
    public Location_StubImpl getLocation(){
        return location;
    }
    
    public void setEvent(Event_DBImpl e){
        event = e;
    }
    
    public void addEvent(){
       // stub
    }
    
    public void setLocation(Location_StubImpl l){
        location = l;
    }
    
}
